package home.game.client.controllers;

import home.game.client.display.MainFrame;
import home.game.client.display.panels.GamePanel;
import home.game.entity.User;

import java.util.Observable;

/**
 */
public class GameController implements Controller {

    private GamePanel gamePanel;
    private User user;


    @Override
    public void initController(Controllable... controllable) {
        this.gamePanel = (GamePanel) controllable[0];


    }

    public void startNewGame() {
        gamePanel.initPanel(user);
        MainFrame.getInstance().initFrame();
    }

    @Override
    public void update(Observable o, Object arg) {
        if (!gamePanel.isInitialized()) {
            user = (User) arg;
            gamePanel.initPanel(user);
            MainFrame.getInstance().initFrame();
        }
    }
}
